<?php  
interface UserInterface{ //����User�Ľӿ�  
 function getname();  
}  
interface TeacherInterface{ //teacher��ؽӿ�  
 function getLengthOfService();  
}  
class User implements UserInterface { //ʵ��UserInterface�ӿ�  
 private $name = "tom";  
 public function getName(){  
  return $this->name;  
 }  
}  
class Teacher implements TeacherInterface { //ʵ��TeacherInterface�ӿ�  
 private $lengthOfService = 5; // ����   
 public function getLengthOfService(){  
  return $this->lengthOfService;  
 }  
}  
// �̳���User��,ͬʱʵ����TeacherInterface�ӿ�.  
class GraduateStudent extends User implements TeacherInterface {  
 private $teacher ;  
 public function __construct(){  
  $this->teacher = new Teacher();    
 }   
 public function getLengthOfService(){  
  return $this->teacher->getLengthOfService();  
 }  
}  
class Act{  
 //ע�������������ʾ�ĳ��˽ӿ�����  
 public static function getUserName(UserInterface $_user){  
  echo "Name is " . $_user->getName() ."<br>";  
 }  
 //�����������ʾ�ĳ���TeacherInterface����.  
 public static function  getLengthOfService(TeacherInterface $_teacher){  
  echo "Age is " .$_teacher->getLengthOfService() ."<br>";  
 }  
}  
$graduateStudent = new GraduateStudent();  
Act::getUserName($graduateStudent);  
Act::getLengthOfService($graduateStudent);  
//�������������Ҫ��,ʵ�����ж�����ݵ�һ������.  
?> 